package cn.devzyh.oms.wsms.api.enums;

import cn.devzyh.oms.wsms.api.constant.StockConstants;
import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 库存位置枚举
 *
 * @author devzyh
 * @date 2023-10-29
 */
@Getter
@RequiredArgsConstructor
public enum StockLocationEnum {

	/**
	 * 可售
	 */
	AVAILABLE(StockConstants.Location.AVAILABLE),

	/**
	 * 退货
	 */
	RETURN(StockConstants.Location.RETURN),

	/**
	 * 残次
	 */
	DEFECTIVE(StockConstants.Location.DEFECTIVE),

	/**
	 * 差异
	 */
	DIFFERENCE(StockConstants.Location.DIFFERENCE);

	/**
	 * 操作类型
	 */
	private final String value;

	/**
	 * 验证值有效性
	 *
	 * @return
	 */
	public static boolean validate(String value) {
		for (StockLocationEnum locationEnum : StockLocationEnum.values()) {
			if (StrUtil.equals(locationEnum.getValue(), value)) {
				return true;
			}
		}
		return false;
	}

}
